//
//  UILabel+Extension.swift
//  Swiftsweibo
//
//  Created by 张鹏飞 on 16/1/2.
//  Copyright © 2016年 张鹏飞. All rights reserved.
//

import UIKit

extension UILabel{

    /// 便利构造函数
    ///
    /// - parameter title:    title
    /// - parameter fontSize: fontSize 默认等于14
    /// - parameter color:    color 默认深灰色
    ///
    /// - returns: UILabel
    convenience init(title: String,fontSize:CGFloat = 14,color: UIColor = UIColor.darkGrayColor(),screenInset: CGFloat = 0){
    
        self.init()
        text = title
        textColor = color
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0
        if screenInset == 0 {
            textAlignment = NSTextAlignment.Center
        } else {
        
            //设置换行高度
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
            textAlignment = .Left
        }
     
    }
}
